/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
* This header file contains some simple data structure definitions
* Use this only to define some simple structures (having no methods)
*
**/
#ifndef LNM_DATA_STRUCTS_H_
#define LNM_DATA_STRUCTS_H_

#include "LnM_math.h"	

/**
* Pixel coordinate structure
* 
*/

/**
* Defines for origin placement
*/
#define ORIGIN_CENTER		0 
#define ORIGIN_UP_LEFT		1
#define ORIGIN_DOWN_LEFT	2


struct TPixelCoord{
	TPixelCoord(){this->x = 0;this->y = 0;} 

	TPixelCoord(int xx, int yy){ 
		this->x = xx;
		this->y = yy;	
	}

	TPixelCoord& operator + (const TPixelCoord& P){
		this->x += P.x;
		this->y += P.y;
		return *this;
	}

	TPixelCoord& operator - (const TPixelCoord& P){
		this->x -= P.x;
		this->y -= P.y;
		return *this;
	}
	TPixelCoord& origin(float size_x, float size_y, float resolution, int origin_placement){
		int xx,yy;
		
		xx = (int)lnm_roundf(size_x / resolution);
		yy = (int)lnm_roundf(size_y / resolution);

		switch(origin_placement){
		case ORIGIN_CENTER:
			this->x = -xx/2;
			this->y = yy/2;
			break;
		case ORIGIN_UP_LEFT:
			this->x = 0;
			this->y = 0;
			break;
		case ORIGIN_DOWN_LEFT:
			this->x = 0;
			this->y = yy;
			break;
		default:
			this->x = 0;
			this->y = 0;
			break;
		}

		return *this;
	}


	
	int x;
	int y;
	
};
	

#endif
